package com.syscom.server.qd.qbean;

import java.io.IOException;

import org.apache.log4j.Logger;

import com.syscom.safe.wac.buf.SacInputBuffer;
import com.syscom.safe.wac.txbean.TxBean;
import com.syscom.safe.wac.txbean.TxContext;
import com.syscom.server.qd.cacheManager.RuleQtaCacheManager;

public class DrawBackQBean extends TxBean {

	private static Logger mLogger = Logger.getLogger(DrawBackQBean.class.getName());

	protected byte[] execute(TxContext ctx, byte[] bData) {
		SacInputBuffer sIn = new SacInputBuffer(bData);
		
		try {
			String sServerId = sIn.readShortString();
			int iRuleId = sIn.readInt();
			String sProdId = sIn.readShortString();
			double dDrawBackValue = sIn.readDouble();
			
			mLogger.debug("Receiver DrawBack from ServerId:[" + sServerId + "], RuleId:[" + iRuleId + "], ProdId:[" + sProdId + "], DrawBackeValue:[" + dDrawBackValue + "]");
			
			RuleQtaCacheManager.getInstance().drawBackToQD(sServerId, iRuleId, sProdId, dDrawBackValue);
		} catch (IOException ex) {
			mLogger.error(ex.getMessage());
			ex.printStackTrace();
		}
		return null;
	}
}
